package top.deo.rpc.system_a.base;

import top.deo.rpc.base.common.Request;
import top.deo.rpc.base.common.Response;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

public class Main {

    public static void main(String[] args) throws Exception {

        Socket socket = new Socket("localhost", 9099);

        ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
        ObjectInputStream in = new ObjectInputStream(socket.getInputStream());

        // 发起请求
        Request request = new Request("top.doe.rpc.base.OrderInfoQuerier", "getOrderAmount", new Class[]{int.class}, new Object[]{100});

        out.writeObject(request);
        out.flush();


        // 接收响应
        Response response = (Response) in.readObject();
        Object result = response.getResult();
        System.out.println("调用成功，返回结果： " + result);

        in.close();
        out.close();
        socket.close();




    }

}
